package com.dgz.common.security.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: DongGuoZhen
 * @Date: 2024/12/10/9:51
 * @Description:
 */

@Component
public class WebMvcConfig implements WebMvcConfigurer {

    @Autowired
    private TokenInterceptor tokenInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(tokenInterceptor)
                .excludePathPatterns("/**/login")   // 排除登录接口
//                .excludePathPatterns("/**/user/sendCode")   // 排除发送验证码接口
                .excludePathPatterns("/**/test/**") // 排除测试接口
                .addPathPatterns("/**");         // 其他接口都要拦截
    }
}
